package com.bs.bsacexj.service.config;

import com.bs.bsacexj.service.Job.UploadACEventInoJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuarzConfig {
    @Bean
    public JobDetail uploadACEventJobDetail() {
        return JobBuilder.newJob(UploadACEventInoJob.class)
                .withIdentity("uploadACEvent", "group1")
                .storeDurably()
                .build();
    }

    //每隔三十秒上传一次进出记录
    @Bean
    public Trigger uploadACEventJobTrigger() {
        SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
                .withIntervalInSeconds(60)  //每30秒执行一次任务
                .repeatForever();

        return TriggerBuilder.newTrigger()
                .forJob(uploadACEventJobDetail())
                .withIdentity("uploadACEventTrigger", "group1")
                .withSchedule(scheduleBuilder)
                .build();
    }

//    //定时上传基础数据
//    @Bean
//    public JobDetail uploadBaseDataJobDetail() {
//        return JobBuilder.newJob(UploadACEventInoJob.class)
//                .withIdentity("uploadBaseData", "group2")
//                .storeDurably()
//                .build();
//    }
//
//    @Bean
//    public Trigger uploadBaseDataJobTrigger() {
//        CronScheduleBuilder schedule = CronScheduleBuilder.cronSchedule("0 0 1 * * ? *");
//        return TriggerBuilder.newTrigger()
//                .forJob(uploadACEventJobDetail())
//                .withIdentity("uploadBaseDataTrigger", "group2")
//                .withSchedule(schedule)
//                .build();
//    }

}


